/*
 * Copyright (c) 2020 - ~, HIT_HERO Team
 *
 * STM32F103C8T6 MIN SYSTEM MAIN SOUCE FILE
 * Used in RT-Thread Operate System
 * Used in MiniSpider Project
 * Yuque Doc: https://www.yuque.com/wangxi_chn/qaxke0/mfns93
 * Gitee: https://gitee.com/WangXi_Chn/MiniSensor
 * 
 * Change Logs:
 * Date           Author       Notes                Mail
 * 2020-09-03     WangXi       first version        WangXi_chn@foxmail.com
 * 2020-09-18     WangXi       second version       WangXi_chn@foxmail.com
 * Note:
 * Finsh: uart1
 * 		uart1_tx -->	PA9
 * 		uart1_rx -->	PA10
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include <stdlib.h>

#include "App_Sensor.h"

APP_SENSOR app_sensor;

int main(void)
{
	APP_Sensor_Config(&app_sensor);
	app_sensor.Method_Run(&app_sensor);

	return 0;
}

/* User Code Begin*/
void MacID(int argc,char **argv)
{
	/* Read machine self ID */
	if (!rt_strcmp(argv[1], "-r")){
        rt_kprintf("Info: My ID is %d\r\n",app_sensor.dev_UartBsp.Property_MyID);
        return;
    }
	
	/* Write machine self ID */
	if (!rt_strcmp(argv[1], "-w")){
		app_sensor.dev_UartBsp.Property_MyID = atoi(argv[2]);
        rt_kprintf("Info: My ID is %d\r\n",app_sensor.dev_UartBsp.Property_MyID);
        return;
    }

    rt_kprintf("Error: error commond!\r\n");
}
MSH_CMD_EXPORT(MacID , MacID <-r|-w ID|...>);

void MacSend(int argc,char **argv)                                                                   
{
	if(argc != 4){
		rt_kprintf("Error: error commond!\r\n");
	}
	
	app_sensor.dev_UartBsp.Value_AimID = (rt_int32_t)atoi(argv[1]);
	app_sensor.dev_UartBsp.Method_Send(&(app_sensor.dev_UartBsp),(rt_int32_t)atoi(argv[2]),(rt_int32_t)atoi(argv[3]));
}
MSH_CMD_EXPORT(MacSend , MacSend <AimID PacketID data|...>);

/************************ (C) COPYRIGHT 2020 WANGXI **************END OF FILE****/

